package cn.dnui_xcz826.dnuifood_16110100826.controller;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;

import java.util.List;

import cn.dnui_xcz826.dnuifood_16110100826.R;
import cn.dnui_xcz826.dnuifood_16110100826.adapter.CommentAdapter;
import cn.dnui_xcz826.dnuifood_16110100826.bean.CommentBean;
import cn.dnui_xcz826.dnuifood_16110100826.listener.onRetrofitListener;
import cn.dnui_xcz826.dnuifood_16110100826.model.CommentModel;

public class MyCommentActivity extends BaseActivity implements onRetrofitListener<List<CommentBean>> {
    private RecyclerView mycomment_rv;
    private ImageView mycomment_return;
    private CommentAdapter adapter;
    void initViews(){
        setLayout(R.layout.activity_my_comment);
        mycomment_rv = (RecyclerView) findViewById(R.id.mycomment_rv);
        mycomment_rv.setLayoutManager(new LinearLayoutManager(MyCommentActivity.this));
        mycomment_return = (ImageView)findViewById(R.id.mycomment_return);
    }
    void initEvents(){
        mycomment_return.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    void initDatas() {

    }

    void initData(){
        CommentModel commentModel=new CommentModel();
        commentModel.getAllCommentsByUser(getUser_id(),this);
    }
    @Override
    public void onSuccess(List<CommentBean> commentInfos, int flag) {
        adapter = new CommentAdapter(MyCommentActivity.this, commentInfos, R.layout.comment_item);
        mycomment_rv.setAdapter(adapter);
    }

    @Override
    public void onFailure(String msg) {
        Toast.makeText(MyCommentActivity.this, "错误", Toast.LENGTH_SHORT).show();
    }

}
